FROM registry.cn-guangzhou.aliyuncs.com/base-namespace/golang:1.21-alpine3.18 AS builder
WORKDIR /app
ENV GO111MODULE=on \
    GOPROXY=https://goproxy.cn,direct
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-w -s --extldflags "-static -fpic"' -o ./bin/crawler ./main.go

FROM alpine

RUN apk add tzdata

WORKDIR /app
# 将上一个阶段publish文件夹下的所有文件复制进来
COPY --from=builder /app/bin/crawler .
COPY ./conf ./conf

ENV profile=${profile}

EXPOSE 8080

CMD /app/crawler --env=${profile:-dev}

